const { defineConfig } = require('@vue/cli-service')
var Mock = require('mockjs')
var data = Mock.mock({
    // 属性 list 的值是一个数组，其中含有 1 到 10 个元素
    'list|6': [{
        // 属性 id 是一个自增数，起始值为 1，每次增 1
        'id|+1': 1,
        "img":"@image(150x150,@color)",
        "title":"@ctitle(4,6)",
        "price|10-100":10,
        "num":1
    }]
})
module.exports = defineConfig({
  transpileDependencies: true,
  devServer: {
    onBeforeSetupMiddleware: function (devServer) {
      if (!devServer) {
        throw new Error('webpack-dev-server is not defined');
      }

      devServer.app.get('/api/list', function (req, res) {
        res.json(data.list);
      });
    },
  },
})
